import http from "@/http/request";

export const getTemplateStyleList: any = () => {
    return http.request({
        url: '/template-categories/all',
        method: 'get'
    });
};

export const templateListGet: any = (params: any) => {
    return http.request({
        url: '/templates/list',
        method: 'post',
        data: params
    });
};

export const uploadResumeAvatar: any = (id:number, data: any) => {
    return http.request({
        url: '/resume/avatar',
        data: data,
        params: {
            resumeId:id
        },
        method: 'post',
    })
}

export const loadResumeAvatar: any =  (id:number) =>{
    return http.request({
        url: `/resume/avatar/${id}`,
        method: 'get',
        responseType: 'arraybuffer'
    })
}

export const getTemplateJsonById: any = (id: number) => {
    return http.request({
        url: `/templates/${id}/json`,
        method: 'get'
    })
}

export const getTemplateById: any = (id: number) => {
    return http.request({
        url: `/templates/by-id/${id}`,
        method: 'get'
    })
}

export const uploadResume: any = (id: number, title: string, cover: string, json: string) => {
    return http.request({
        url: `/resume/save`,
        data: {
            templateId: id,
            title: title,
            templateCover: cover,
            resumeJson: JSON.stringify(json)
        },
        method: 'post'
    });
}

export const updateResume: any = (id: number, title: string, cover: string, json: string) => {
    return http.request({
        url: `/resume/update`,
        data: {
            resumeId: id,
            title: title,
            templateCover: cover,
            templateJson: JSON.stringify(json)
        },
        method: 'post'
    });
}

export const getResumeJsonById: any = (id: number) => {
    return http.request({
        url: `/resume/json-content`,
        data: {
            resumeId: id
        },
        method: 'post'
    });
}

export const getResumeById: any = (id: number) => {
    return http.request({
        url: `/resume/detail`,
        data: {
            resumeId: id
        },
        method: 'post'
    });
}

export const getResumeList: any = (page: number, limit: number) => {
    return http.request({
        url: `/resume/list`,
        data: {
            page: page,
            limit: limit
        },
        method: 'post'
    });
}

export const aiResume: any = (data: any) => {
    return http.request({
        url: `/resume/ai-generate`,
        data: data,
        method: 'post'
    })
}

export const deleteResume: any = (id: number) => {
    return http.request({
        url: `/resume/delete`,
        method: 'post',
        data: {
            resumeId: id
        }
    })
}

export const getResumeScore: any = (id: number) => {
    return http.request({
        url: `/resume/scores`,
        method: 'post',
        data: {
            resumeId: id,
            forceRegenerate: false
        }
    })
}

export const getResumeRevisionSuggestions: any = (data : any) => {
    return http.request({
        url: `/resume/ai-optimize`,
        data: data,
        method: 'post'
    })
}